<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Taxx\KernelBundle\Model\Utils;

/**
 * Description of PasswordUtils
 *
 * @author flocki
 */
class PasswordUtils 
{
    public static $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!?&$";

    public static function generateRawPassword()
    {
        return substr(str_shuffle(str_shuffle(self::$source)), 0, 6);
    }
    
    public static function getSalt()
    {
        return substr(str_shuffle(str_shuffle(self::$source)), 0, 10);
    }
    
    public static function generatePassword($raw, $salt)
    {
        return substr(sha1($raw.$salt), 0, 50);
    }
    
    public static function verifyPassword($raw, $salt, $password)
    {
        echo substr(sha1($raw.$salt), 0, 50)." == ".$password."<br />";
        if(substr(sha1($raw.$salt), 0, 50)==$password)
            return true;
        else
            return false;
    }
}

?>
